#include "gtest/gtest.h"
#include "App.h"

TEST(AppTest, main){
    int argc = 0;
    char * argv[] = {
        (char*)"-h",
    };

    App app;
    app.run(argc, argv);
}

#include "BreakPointService.h"
TEST(BreakPointServiceTest, use){
    BreakPointService bpService;

    bpService.start();
    bpService.connected();
    bpService.receivedLoginResp("loginrsp-0-OK");

    bpService.timeout(); 
    bpService.receivedBreakPointResp("breakpoint-0-OK");

    bpService.receivedNormalResp("normal_1-0-OK");
    bpService.receivedNormalResp("normal_2-0-OK");
    bpService.receivedNormalResp("normal_3-0-OK");

    bpService.disconnected();
    
    bpService.stop();
}


#include "BreakPointMem.h"
TEST(BreakPointMemTest, use){
    BreakPointMem bpMem;

    ASSERT_EQ(bpMem.get(), -1);

    long long seqNo = 10001;
    bpMem.set(seqNo);
    ASSERT_EQ(bpMem.get(), seqNo);
}

#include "BreakPointFile.h"
TEST(BreakPointFileTest, use){
    BreakPointFile bpFile("seqNo.bin");
    
    ASSERT_STREQ("seqNo.bin", bpFile.getFilePath().c_str());
    ASSERT_EQ(-1, bpFile.getSeqNo());

    const long long defSeqNo = 10001;
    ASSERT_EQ(defSeqNo, bpFile.loadFromFile());
    ASSERT_EQ(defSeqNo, bpFile.getSeqNo());


    const long long newSeqNo = defSeqNo + 1;
    bpFile.saveToFile(newSeqNo);
    ASSERT_EQ(newSeqNo, bpFile.getSeqNo());
}
